package de.op.projectc.screens;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;

import de.op.projectc.MainGame;

public class MainMenuScreen implements Screen {

	final MainGame game;
	private Stage stage;
	private Skin skin;
	Label timeLabel;
	
	private float timeElapsed; 
	
	public MainMenuScreen(final MainGame game) {
		this.game = game;
		
		stage = new Stage();
	    Gdx.input.setInputProcessor(stage);
	    skin = new Skin(Gdx.files.internal("ui/uiskin.json"));
	    
	    timeLabel = new Label("5", skin);
	    timeLabel.setPosition(Gdx.graphics.getWidth() / 2, Gdx.graphics.getHeight() / 2 - 10);
	    
	    stage.addActor(timeLabel);
	    
	    timeElapsed = 0f;
	}
	
	@Override
	public void dispose() {
		
	}

	@Override
	public void hide() {
		
	}

	@Override
	public void pause() {
		
	}

	@Override
	public void render(float delta) {
		timeElapsed += delta;
		
		stage.act(Gdx.graphics.getDeltaTime());
        stage.draw();
        
		if(timeElapsed >= 2.0f)
			game.setScreen(new GameScreen(game));
		
		this.timeLabel.setText(Integer.toString((int) (2 - timeElapsed)) + "...");
	}

	@Override
	public void resize(int width, int height) {
		stage.setViewport(width, height, false);
	}

	@Override
	public void resume() {
		
	}

	@Override
	public void show() {
		
	}

}
